package com.burgess.net.borker;

import org.apache.activemq.broker.BrokerFactory;
import org.apache.activemq.broker.BrokerService;

import java.net.URI;

/**
 * 使用broker来构建应用
 * 创建人    BurgessLee
 * 创建时间   2020/5/21
 * 描述
 */
public class BrokerApplication {

    public static void main(String[] args) throws Exception {
        /**
         * 第一种方式：Broker Service启动broker
         */
        BrokerService brokerService = new BrokerService();
        brokerService.setUseJmx(true);
        brokerService.addConnector("tcp://localhost:61616");
        brokerService.start();

        /**
         * 第二种方式:使用BrokerFactory来启动broker
         */
        String uri = "properties:broker.properties";
        BrokerService broker = BrokerFactory.createBroker(new URI(uri));
        broker.addConnector("tcp://localhost:61616");
        broker.start();
    }

}
